<div class="edit-content">
  <div class="edit-header">
    {{#if CAN.EDIT_TITLE}}
      {{#if content_is_locked}}
        <h1>{{title}}</h1>
        <input name="title" type="hidden" value="{{title}}">
      {{else}}
        <label for="title" class="screenreader-only">{{#t "title_label"}}Page Title{{/t}}</label>
        <input id="title" name="title" type="text" class="span4 title" value="{{title}}" maxlength="255" autofocus>
      {{/if}}
    {{else}}
      <h2>{{title}}</h2>
    {{/if}}
    {{#unless content_is_locked}}
      <div class="switch_views_container">
        <div class="help_dialog"></div>
        <a href="#" class="switch_views">
          {{#t "#editor.switch_editor_html"}}HTML Editor{{/t}}
        </a>
        <a href="#" class="switch_views" style="display:none;">
          {{#t "#editor.switch_editor_rich_text"}}Rich Content Editor{{/t}}
        </a>
      </div>
    {{/unless}}
  </div>

  {{#if content_is_locked}}
    {{{body}}}
  {{else}}
    <textarea id="wiki_page_body" rows="20" cols="40" name="body" class="body" aria-hidden="true"{{#unless PAGE_RIGHTS.update}} autofocus{{/unless}}>{{convertApiUserContent body forEditing=1}}</textarea>
  {{/if}}

  {{#if CAN.EDIT_ROLES}}
    <div class="control-group options">
      <label class="control-label"><strong>{{#t "options_label"}}Options{{/t}}</strong></label>
      <div class="controls">
        <label id="editing_roles_label"  for="editing_roles">{{t "Can edit this page role selection"}}</label>
        <select id="editing_roles" aria-label="{{t "Can edit this page role selection"}}" name="editing_roles">
          {{#if SHOW.COURSE_ROLES}}
            <option value="teachers"{{#if IS.TEACHER_ROLE}} selected{{/if}}>{{#t "course_editing_roles.only_teachers"}}Only teachers{{/t}}</option>
            <option value="teachers,students"{{#if IS.STUDENT_ROLE}} selected{{/if}}>{{#t "course_editing_roles.teachers_and_students"}}Teachers and students{{/t}}</option>
            <option value="teachers,students,public"{{#if IS.ANYONE_ROLE}} selected{{/if}}>{{#t "course_editing_roles.anyone"}}Anyone{{/t}}</option>
          {{else}}
            <option value="members"{{#if IS.MEMBER_ROLE}} selected{{/if}}>{{#t "editing_roles.only_members"}}Only members{{/t}}</option>
            <option value="members,public"{{#if IS.ANYONE_ROLE}} selected{{/if}}>{{#t "editing_roles.anyone"}}Anyone{{/t}}</option>
          {{/if}}
        </select>
      </div>
      {{#if ENV.student_planner_enabled}}
        <div class="controls">
          <label for="student_planner_checkbox" class="checkbox">
          <input value="1" type="checkbox" id="student_planner_checkbox" name="student_planner_checkbox" {{checkedIf todo_date}} />
            {{#t}}Add to student to-do{{/t}}
          </label>
          <div id="todo_date_container">
            <label class="screenreader-only" for="todo_date" id="student_planner_accessible_label">
              {{#t}}Student Planner Date:{{/t}}
              {{datepickerScreenreaderPrompt}}
            </label>
            <input type="text"
                   class="datetime_field input-medium"
                   name="student_todo_at"
                   id="todo_date"
                   aria-labelledby="student_planner_accessible_label"
                   {{! TODO: what would be the best way to get this formatted right? }}
                   value="{{datetimeFormatted todo_date}}"
                   data-tooltip='{"position":"top","force_position":"true"}'
                   title="{{accessibleDateFormat}}"/>
          </div>
        </div>
      {{/if}}
      {{#if ENV.CONDITIONAL_RELEASE_SERVICE_ENABLED}}
        <div class="controls">
          <label class="checkbox" for="conditional_content">
            {{checkbox "assignment.set_assignment"
              id="conditional_content"
              class="element_toggler"
              checked=set_assignment}}
            {{#t}}Allow in mastery paths{{/t}}
          </label>
        </div>
      {{/if}}
    </div>
  {{/if}}
</div>

<div class="form-actions clearfix">
  <div>
    <label for="notify_of_update" class="checkbox clearfix pull-left" style="margin-top:5px">
      {{checkbox "notify_of_update"}}
      {{#t "notify_users_text"}}Notify users that this content has changed{{/t}}
    </label>
    <button class="btn cancel">{{#t "buttons.cancel"}}Cancel{{/t}}</button>
    {{#if CAN.PUBLISH_NOW}}
      <button class="btn btn-default save_and_publish">{{#t "buttons.save_and_publish"}}Save & Publish{{/t}}</button>
    {{/if}}
    <button class="btn btn-primary submit">{{#t "buttons.save"}}Save{{/t}}</button>
  </div>
</div>
